#ifndef WIN_EXCEPTION_H
#define WIN_EXCEPTION_H

#include <stdexcept>
#include <Windows.h>
#include "x_except.hpp"

struct win_exception: public data_exception<DWORD, std::runtime_error>
{
  win_exception(std::string m, DWORD er);
  ~win_exception() {}
  virtual const char* what() const throw()
  {
    return msg;
  }
};


#define X_WIN_ERROR_THROW_IF(cond, ret, whatarg) \
  X_THROW_IF(cond, win_exception(whatarg, ret))

#define X_WIN_THROW_IF(cond, whatarg) \
  X_WIN_ERROR_THROW_IF(cond, GetLastError(), whatarg)

#define X_WIN_THROW_IF_NULL(return_value, whatarg) \
  X_WIN_THROW_IF(return_value==0, whatarg)


#endif

